<template xmlns="http://www.w3.org/1999/html">
  <div class="app_main">
    <div class="header">合同信息</div>
    <div class="table_body" style="position: relative">
      <el-form ref="cuForm" v-loading="formLoading" class="cuForm" :rules="cuRules" :model="cuForm"
               label-width="100px" center size="mini"
               :disabled="formDisabled"
      >
        <div class="contract_title">合同编号：
          <span :class="cuForm.contract_num?'text-red':''">
            {{ cuForm.contract_num ? cuForm.contract_num : '提交后自动生成编号' }}
          </span>
        </div>
        <div class="contract_content">
          <p>
            <el-form-item prop="contract_begin_date" label-position="right" label="合同时间：" style="display:inline-flex;">
              <el-date-picker v-model="cuForm.contract_begin_date" type="date" placeholder="开始时间"
                              value-format="yyyy-MM-dd" format="yyyy年MM月dd日" style="width: 240px"
              />
            </el-form-item>
            至
            <el-form-item prop="contract_end_date" label-position="right" style="display:inline-flex;">
              <el-date-picker v-model="cuForm.contract_end_date" type="date" placeholder="结束时间"
                              value-format="yyyy-MM-dd" format="yyyy年MM月dd日" style="width: 240px"/>
            </el-form-item>
          </p>
          <p>
            <el-col :span="12">
            <el-form-item prop="customer_id" label-position="right" label="项目名称：" style="display:inline-flex;">
              <el-select v-model="cuForm.customer_id" clearable filterable style="width: 240px;"
                         placeholder="请选择项目"
                         @change="getHistoryUser"

              >
                <el-option v-for="customer in customer_arr" :key="customer.id" :label="customer.name"
                           :value="customer.id"
                />
              </el-select>
            </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item prop="sign_date" label-position="right" label="签订时间：" style="display:inline-flex;">
                <el-date-picker v-model="cuForm.sign_date" type="date" placeholder="合同签订时间"
                                value-format="yyyy-MM-dd" format="yyyy年MM月dd日" style="width: 240px"
                />
              </el-form-item>
            </el-col>
          </p>
          <p>
             <el-col :span="12">
            <el-form-item prop="part_a" label="甲方名称：" label-position="right" style="display:inline-flex;">
              <el-select v-model="cuForm.part_a" filterable allow-create placeholder="请选择甲方名称" style="width: 240px;">
                <el-option v-for="(part_a,index) in part_a_history_list"
                           :key="index"
                           :label="part_a"
                           :value="part_a"
                />
              </el-select>
            </el-form-item>
            </el-col>
            <el-col :span="12">
            <el-form-item prop="part_b_name" label="乙方名称：" label-position="right" style="display:inline-flex;" >
              <el-select v-model="selectDept" clearable value-key="id" placeholder="请选择乙方名称" style="width: 240px;"
                         @change="selectDeptChange"
              >
                <el-option v-for="(item,index) in dept_list" :key="index" :value="item"
                           :label="item.head"
                />
              </el-select>
            </el-form-item>
            </el-col>
          </p>
          <p><span class="p_title">第一条：</span>合作单价：</p>
          <div>
            <el-table :header-row-style="{'line-height':'38px'}" class="fill_table" :data="cuForm.mediaDetailList"
                      stripe border
                      style="width: 80%;margin: 10px auto"
            >
              <el-table-column label="媒体类型" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'mediaDetailList.'+scope.$index+'.media_type_id'"
                                :rules="{required: true, message: '媒体类型不能为空', trigger: 'change'}"
                  >
                    <el-select v-model="scope.row.media_type_id" size="mini" placeholder="请选择媒体类型" @change="(val)=>{
                      mediaTypeChange(scope.$index,val)
                    }">
                      <el-option v-for="item in point_type_arr" :key="item.id" :value="item.id" :label="item.name"/>
                    </el-select>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column label="规格" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'mediaDetailList.'+scope.$index+'.media_type_spec_id'"
                                :rules="{required: true, message: '规格不能为空', trigger: 'change'}"
                  >
                    <el-select v-model="scope.row.media_type_spec_id" size="mini" placeholder="请选择规格">
                      <el-option v-for="(item,index) in scope.row.media_type_spec_arr" :key="index" :value="item"
                                 :label="item"
                      />
                    </el-select>
                  </el-form-item>
                </template>
              </el-table-column>

              <el-table-column label="谈判单价" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'mediaDetailList.'+scope.$index+'.talk_price'"
                                :rules="{required: true, message: '谈判单价不能为空', trigger: 'blur'}">
                    <el-input v-model="scope.row.talk_price" size="mini" placeholder="请输入谈判单价"/>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column label="执行单价" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'mediaDetailList.'+scope.$index+'.price'">
                    <el-input v-model="scope.row.price" size="mini" readonly placeholder="执行单价自动计算"/>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column label="数量" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'mediaDetailList.'+scope.$index+'.quantity'"
                                :rules="{required: true, message: '数量不能为空', trigger: 'blur'}"
                  >
                    <el-input v-model="scope.row.quantity" type="number" step="0.01" size="mini" placeholder="请输入数量"/>
                  </el-form-item>
                </template>
              </el-table-column>

              <el-table-column label="时长/周期" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'mediaDetailList.'+scope.$index+'.media_cycle'">
                    <el-input v-model="scope.row.media_cycle" type="number" size="mini" placeholder="请输入周期" />
                    <el-select v-model="scope.row.media_cycle_unit" size="mini" placeholder="请选择单位">
                      <el-option v-for="(unit,index) in media_cycle_unit_arr" :key="index" :value="unit.key" :label="unit.name"/>
                    </el-select>
                  </el-form-item>
                </template>
              </el-table-column>

              <el-table-column label="金额" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'mediaDetailList.'+scope.$index+'.amount'"
                                :rules="{required: true, message: '金额不能为空', trigger: 'blur'}"
                  >
                    <el-input v-model="scope.row.amount" type="number" step="0.01" size="mini" placeholder="请输入金额">
                      <template slot="append">元</template>
                    </el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column v-if="!formDisabled" width="50" align="center">
                <template slot="header">
                  <i style="color: #00c300;font-size: 20px;line-height: 38px" class="el-icon-circle-plus-outline"
                     @click="myAdd"
                  />
                </template>
                <template slot-scope="scope">
                  <i style="color: #da0000;font-size: 20px;line-height: 38px" class="el-icon-remove-outline"
                     @click="myDeleteByIndex(scope.$index)"
                  />
                </template>
              </el-table-column>
            </el-table>
            <el-table :header-row-style="{'line-height':'38px'}" class="fill_table" :data="cuForm.proxyMediaDetailList"
                      stripe border
                      style="width: 80%;margin: 10px auto"
            >
              <el-table-column label="代理媒体" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'proxyMediaDetailList.'+scope.$index+'.proxy_media_type'"
                                :rules="{required: true, message: '代理媒体不能为空', trigger: 'blur'}"
                  >
                    <el-input v-model="scope.row.proxy_media_type" placeholder="请输入代理媒体"/>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column label="规格" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'proxyMediaDetailList.'+scope.$index+'.media_type_spec'"
                                :rules="{required: true, message: '规格不能为空', trigger: 'blur'}"
                  >
                    <el-input v-model="scope.row.media_type_spec" placeholder="请输入规格"/>
                  </el-form-item>
                </template>
              </el-table-column>

              <el-table-column label="谈判单价" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'proxyMediaDetailList.'+scope.$index+'.talk_price'"
                                :rules="{required: true, message: '谈判单价不能为空', trigger: 'blur'}">
                    <el-input v-model="scope.row.talk_price" size="mini" placeholder="请输入谈判单价"/>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column label="执行单价" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'proxyMediaDetailList.'+scope.$index+'.price'">
                    <el-input v-model="scope.row.price" size="mini" readonly placeholder="执行单价自动计算"/>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column label="数量" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'proxyMediaDetailList.'+scope.$index+'.quantity'"
                                :rules="{required: true, message: '数量不能为空', trigger: 'blur'}"
                  >
                    <el-input v-model="scope.row.quantity" type="number" step="0.01" size="mini" placeholder="请输入数量"/>
                  </el-form-item>
                </template>
              </el-table-column>

              <el-table-column label="时长/周期" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'proxyMediaDetailList.'+scope.$index+'.media_cycle'">
                    <el-input v-model="scope.row.media_cycle" type="number" size="mini" placeholder="请输入周期" />
                    <el-select v-model="scope.row.media_cycle_unit" size="mini" placeholder="请选择单位">
                      <el-option v-for="(unit,index) in media_cycle_unit_arr" :key="index" :value="unit.key" :label="unit.name"/>
                    </el-select>
                  </el-form-item>
                </template>
              </el-table-column>

              <el-table-column label="金额" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'proxyMediaDetailList.'+scope.$index+'.amount'"
                                :rules="{required: true, message: '金额不能为空', trigger: 'blur'}">
                    <el-input v-model="scope.row.amount" size="mini" type="number" step="0.01" placeholder="请输入金额">
                      <template slot="append">元</template>
                    </el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column v-if="!formDisabled" width="50" align="center">
                <template slot="header">
                  <i style="color: #00c300;font-size: 20px;line-height: 38px" class="el-icon-circle-plus-outline"
                     @click="add"
                  />
                </template>
                <template slot-scope="scope">
                  <i style="color: #da0000;font-size: 20px;line-height: 38px" class="el-icon-remove-outline"
                     @click="deleteByIndex(scope.$index)"
                  />
                </template>
              </el-table-column>
            </el-table>

          </div>

          <el-row :gutter="24">
            <p v-if="cuForm.old_data">
              2、画面更换费用另计：
              <el-input v-model="cuForm.replace_price" style="width: 200px" size="mini"
                        oninput="value=value.replace(/[^\d.]/g,'')" placeholder="请输入画面更换费用"
              />
              元/幅/次
            </p>
            <p v-if="!cuForm.old_data">
              2、画面更换费用另计：
            </p>
            <p v-if="!cuForm.old_data">
              <el-col :span="12">
                  <el-table style="margin: 0 auto" class="fill_table"
                            :data="cuForm.contractMediaReplacePriceList" stripe border
                            :header-row-style="{'line-height':'38px'}"
                  >
                    <el-table-column label="自有资源媒体类型" align="center">
                      <template slot-scope="scope">
                        <el-form-item style="margin: 18px 0"
                                      :prop="'contractMediaReplacePriceList.'+scope.$index+'.media_type_id'"
                                      :rules="{required: true, message: '媒体类型不能为空', trigger: 'change'}"
                        >
                          <el-select v-model="scope.row.media_type_id" size="mini" placeholder="请选择媒体类型">
                            <el-option v-for="item in point_type_arr" :key="item.id" :value="item.id" :label="item.name"/>
                          </el-select>
                        </el-form-item>
                      </template>
                    </el-table-column>
                    <el-table-column label="价格" align="center">
                      <template slot-scope="scope">
                        <el-form-item style="margin: 18px 0"
                                      :prop="'contractMediaReplacePriceList.'+scope.$index+'.replace_price'"
                                      :rules="{required: true, message: '价格不能为空', trigger: 'blur'}"
                        >
                          <el-input v-model="scope.row.replace_price" type="number" step="0.01" size="mini"
                                    placeholder="请输入价格"
                          >
                            <template slot="append">元/幅/次</template>
                          </el-input>
                        </el-form-item>
                      </template>
                    </el-table-column>
                    <el-table-column v-if="!formDisabled" width="50" align="center">
                      <template slot="header">
                        <i style="color: #00c300;font-size: 20px;line-height: 38px" class="el-icon-circle-plus-outline"
                           @click="priceAdd(1)"
                        />
                      </template>
                      <template slot-scope="scope">
                        <i style="color: #da0000;font-size: 20px;line-height: 38px" class="el-icon-remove-outline"
                           @click="priceRemove(1,scope.$index)"
                        />
                      </template>
                    </el-table-column>
                  </el-table>
              </el-col>
              <el-col :span="12">
                <el-table style="margin: 0 auto" class="fill_table"
                          :data="cuForm.contractProxyMediaReplacePriceList" stripe border
                          :header-row-style="{'line-height':'38px'}"
                >
                  <el-table-column label="代理资源媒体类型" align="center">
                    <template slot-scope="scope">
                      <el-form-item style="margin: 18px 0"
                                    :prop="'contractProxyMediaReplacePriceList.'+scope.$index+'.media_type_name'"
                                    :rules="{required: true, message: '媒体类型不能为空', trigger: 'blur'}"
                      >
                        <el-input v-model="scope.row.media_type_name" size="mini" placeholder="请输入媒体类型" clearable>
                        </el-input>
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column label="价格" align="center">
                    <template slot-scope="scope">
                      <el-form-item style="margin: 18px 0"
                                    :prop="'contractProxyMediaReplacePriceList.'+scope.$index+'.replace_price'"
                                    :rules="{required: true, message: '价格不能为空', trigger: 'blur'}"
                      >
                        <el-input v-model="scope.row.replace_price" type="number" step="0.01" size="mini"
                                  placeholder="请输入价格"
                        >
                          <template slot="append">元/幅/次</template>
                        </el-input>
                      </el-form-item>
                    </template>
                  </el-table-column>
                  <el-table-column v-if="!formDisabled" width="50" align="center">
                    <template slot="header">
                      <i style="color: #00c300;font-size: 20px;line-height: 38px" class="el-icon-circle-plus-outline"
                         @click="priceAdd(2)"
                      />
                    </template>
                    <template slot-scope="scope">
                      <i style="color: #da0000;font-size: 20px;line-height: 38px" class="el-icon-remove-outline"
                         @click="priceRemove(2,scope.$index)"
                      />
                    </template>
                  </el-table-column>
                </el-table>
              </el-col>
            </p>
          </el-row>
           <p><span class="p_title">第三条：</span>合同金额及付款方式：</p>
          <p style="margin-top: 15px;line-height: 28px;">
            优惠价格：{{cuForm.discounted_price ? cuForm.discounted_price : '0' }}元(大写 {{ cuForm.discounted_price_big }})，
            <el-form-item label="是否含税：">
              <el-checkbox v-model="cuForm.contain_tax"/>
            </el-form-item>
            <span v-show="cuForm.contain_tax">
              ，（开票另计
              <el-input v-model="cuForm.tax_percent" size="mini" style="width: 100px" type="number" step="0.01"/>
              %的税费，发票类型：<el-select v-model="cuForm.invoice_type" placeholder="请选择发票" clearable>
                      <el-option :value="0" label="普票"/>
                      <el-option :value="1" label="专票"/>
                    </el-select>）,
            </span>
            自有资源：{{ cuForm.self_price ? cuForm.self_price : '0' }}元(大写 {{ cuForm.self_price_big }})，代理资源：{{ cuForm.proxy_price ? cuForm.proxy_price : '0' }}元(大写 {{ cuForm.proxy_price_big }})。支付方式：现金人民币
            {{ cuForm.pay_cash_amount ? cuForm.pay_cash_amount : '0' }}元
            ，(大写 {{ cuForm.pay_cash_amount_big }} )；置换人民币
            {{ cuForm.displace_amount ? cuForm.displace_amount : '0' }}元
            ，(大写 {{ cuForm.displace_amount_big }} )<br>
            备注：
            <el-input v-model="cuForm.memo" type="textarea" placeholder="请输入备注"/>
            <el-table :header-row-style="{'line-height':'38px'}" class="fill_table" :data="cuForm.payDetailList"
                      style="margin-top: 10px" border
            >
              <el-table-column label="付款时间" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'payDetailList.'+scope.$index+'.pay_time'"
                                :rules="{required: true, message: '付款时间不能为空', trigger: 'change'}"
                  >
                    <el-date-picker
                      v-model="scope.row.pay_time"
                      type="date"
                      placeholder="请选择付款时间"
                      value-format="yyyy-MM-dd"
                      format="yyyy年MM月dd日"
                    />
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column label="付款金额" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'payDetailList.'+scope.$index+'.pay_amount'"
                                :rules="{required: true, message: '付款金额不能为空', trigger: 'blur'}"
                  >
                    <el-input v-model="scope.row.pay_amount" placeholder="请输入付款金额" type="number" step="0.01">
                      <template slot="append">元</template>
                    </el-input>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column label="付款方式" align="center">
                <template slot-scope="scope">
                  <el-form-item style="margin: 18px 0" :prop="'payDetailList.'+scope.$index+'.pay_type'"
                                :rules="{required: true, message: '付款方式不能为空', trigger: 'change'}"
                  >
                    <el-select v-model="scope.row.pay_type" placeholder="请选择付款方式" clearable>
                      <el-option :value="1" label="现金"/>
                      <el-option :value="2" label="置换"/>
                    </el-select>
                  </el-form-item>
                </template>
              </el-table-column>
              <el-table-column v-if="!formDisabled" width="50" align="center">
                <template slot="header">
                  <i style="color: #00c300;font-size: 20px;line-height: 38px" class="el-icon-circle-plus-outline"
                     @click="addPay"
                  />
                </template>
                <template slot-scope="scope">
                  <i style="color: #da0000;font-size: 20px;line-height: 38px" class="el-icon-remove-outline"
                     @click="deletePayByIndex(scope.$index)"
                  />
                </template>
              </el-table-column>
            </el-table>
          </p>
          <p><span class="p_title">第四条：</span>支付方式</p>
          <p>，验收方式：
            <el-select v-model="cuForm.acceptance_way" size="mini" clearable >
              <el-option value="A"/>
              <el-option value="B"/>
            </el-select>。合同优惠价格中只包含首次视频画面编辑制作费用，如需多次更换视频画面内容，以
            <el-input v-model="cuForm.multi_replace_price" style="width: 150px" size="mini" placeholder="请输入更换视频费用"
                      type="number" step="0.01"
            />
            元/张内容计算。
          </p>
        </div>
        <div class="two_title">附件信息</div>
        <div style="width: 80%;margin: 10px auto">
          <el-button type="primary" size="mini" :disabled="!canUpload" @click="showContractUpload">上传合同</el-button>
        </div>
        <el-table :data="cuForm.attachmentList" size="mini" border stripe style="width: 80%;margin: 0 auto">
          <el-table-column label="序号" width="50" align="center">
            <template slot-scope="scope">
              {{ scope.$index + 1 }}
            </template>
          </el-table-column>
          <el-table-column label="合同名称" prop="name" min-width="300" align="center"/>
          <el-table-column label="操作" width="250" align="center">
            <template slot-scope="scope">
              <el-button-group>
                <el-button size="mini" type="success" :disabled="false" @click="look(scope.row.url)">预览
                </el-button>
                <el-button size="mini" type="primary" :disabled="false" @click="download(scope.row.url)">下载查看
                </el-button>
                <el-button size="mini" type="danger" @click="removeContract(scope.$index)">删除</el-button>
              </el-button-group>
            </template>
          </el-table-column>
        </el-table>
        <div style="width: 80%;margin: 10px auto">
          <el-button type="primary" size="mini" :disabled="!canUpload" @click="showOtherUpLoad">上传其他资料</el-button>
        </div>
        <el-table :data="cuForm.documentList" size="mini" border stripe style="width: 80%;margin: 0 auto">
          <el-table-column label="序号" width="50" align="center">
            <template slot-scope="scope">
              {{ scope.$index + 1 }}
            </template>
          </el-table-column>
          <el-table-column label="资料名称" prop="name" min-width="300" align="center"/>
          <el-table-column label="操作" width="250" align="center">
            <template slot-scope="scope">
              <el-button-group>
                <el-button size="mini" type="success" :disabled="false" @click="look(scope.row.url)">预览
                </el-button>
                <el-button size="mini" type="primary" :disabled="false" @click="download(scope.row.url)">下载查看
                </el-button>
                <el-button size="mini" type="danger" @click="removeAttachment(scope.$index)">删除</el-button>
              </el-button-group>
            </template>
          </el-table-column>
        </el-table>

      </el-form>
    </div>
    <FlowBtnRow style="margin-bottom: 10px" :form-name="'cuForm'" :is-new-data="is_created"
                :can-check="cuForm.can_check"
                :is-applyer="cuForm.flow_applyer_id == user_id" :flow-status="cuForm.flow_status"
                :flow-type="17" :data-id="(params || {}).id || ((params || {}).handle_param || {}).id" @save="save"
                @submit="submit" @pass="pass"
                @returnBack="returnBack" @delete="remove"
                @actualDelete="actualDelete"
    />
    <contract-upload :upload-dialog-show="contractUploadShow" type="1" @close="closeContractUpload" @success="uploadSuccess"/>

    <contract-upload :upload-dialog-show="attachUploadShow" type="2" @close="closeAttachUpload" @success="uploadSuccess"/>

  </div>
</template>

<script>
import FlowBtnRow from '@/components/FlowBtnRow/index'
import { list as getPlanList } from '@/api/business/intention_scheme'
import { actual_delete, begin, detail, part_a_history, pass, remove, return_back, save, saveAttachment } from '@/api/contract'
import { get_company } from '@/api/system/department'
import contractUpload from '@/components/contractUpload/index'
import {add, amountToBigStr, divide, multiply} from '@/utils/amount'
import { company_list_all, list_all } from '@/api/customer/customer'
import { list_media_types } from '@/api/building/building'
import { list_media_type_include_proxy } from '@/api/point/media'
import { list_by_media_type_id, listTypeSpecByMediaTypeId } from '@/api/media/specs'

export default {
  name: 'Detail',
  components: { FlowBtnRow, contractUpload },
  data() {
    return {
      type: 1,
      tmpIndex: -1,
      date_range: [],
      buildingList: [],
      disabled: false,
      is_created: false,
      exclude_building_id_list: [],
      exclude_media_id_list: [],
      pointTypeIdList: [],
      positionSelectionDialogVisible: false,
      showCreatePointType: false, // 是否显示选择点位创建方式的盒子
      showInfo: true,
      formLoading: false,
      cuRules: {
        part_a: [
          { required: true, message: '请输入甲方名称', trigger: 'blur' }
        ],
        part_a_phone: [
          { required: true, message: '请输入甲方联系方式', trigger: 'blur' }
        ],
        customer_id: [
          { required: true, message: '请选择客户', trigger: 'change' }
        ],
        part_b_name: [
          { required: true, message: '请选择乙方', trigger: 'change' }
        ],
        part_b_phone: [
          { required: true, message: '请输入乙方联系方式', trigger: 'blur' }
        ],
        // discounted_price: [
        //   { required: true, message: '请输入优惠价格', trigger: 'blur' }
        // ],
        // part_a_contact: [
        //   { required: true, message: '请输入甲方经办人联系方式', trigger: 'blur' }
        // ],
        // part_b_contact: [
        //   { required: true, message: '请输入乙方经办人联系方式', trigger: 'blur' }
        // ],
        bank_account_name: [
          { required: true, message: '请输入开户名', trigger: 'blur' }
        ],
        // 开户行名
        bank_name: [
          { required: true, message: '请输入开户行', trigger: 'blur' }
        ],
        // 开户号
        bank_num: [
          { required: true, message: '请输入账号', trigger: 'blur' }
        ],
        // 合同开始日期
        contract_begin_date: [
          { required: true, message: '请选择合同开始日期', trigger: 'change' }
        ],
        // 合同结束日期
        contract_end_date: [
          { required: true, message: '请选择合同结束日期', trigger: 'change' }
        ],
        // 签订日期
        sign_date: [
          { required: true, message: '请选择签订日期', trigger: 'change' }
        ]
      },
      flag: true, // true为关联方案 false为选点
      customer_arr: [],
      centerDialogVisible: false,
      selectDept: null,
      selectPartA: null,
      media_cycle_unit_arr: [
        {"key":"day", "name": "天"},
        {"key":"week", "name": "周"},
        {"key":"month", "name": "月"}
      ],
      cuForm: {
        id: null,
        // 合同编号
        contract_num: null,
        // 客户ID（项目名称）
        customer_id: null,
        // 甲方
        part_a: null,
        // 乙方id
        part_b_id: null,
        // 乙方名称
        part_b_name: null,
        // 甲方人联系方式
        part_a_contact: null,
        // 乙方人联系方式
        part_b_contact: null,
        // 开户名
        bank_account_name: null,
        // 开户行名
        bank_name: null,
        // 开户号
        bank_num: null,
        // 合同开始日期
        contract_begin_date: null,
        // 合同结束日期
        contract_end_date: null,
        // 签订日期
        sign_date: null,
        // 优惠价格
        discounted_price: 0,
        // 优惠价格（大写)
        discounted_price_big: '零元整',
        // todo new
        // 是否含税
        contain_tax: false,
        // 发票类型
        invoice_type: 0,//0普票 1专票
        // todo new
        // 另收**%税费
        tax_percent: null,
        // 自有资源价格
        self_price: 0,
        // todo new
        // 自有资源价格（大写)
        self_price_big: '零元整',
        // 代理资源价格")
        proxy_price: 0,
        // todo new
        // 代理资源价格（大写）
        proxy_price_big: '零元整',
        // 画面更换价格
        replace_price: null,
        // todo new
        // 现金支付金额
        pay_cash_amount: 0,
        // todo new
        // 现金支付金额（大写）
        pay_cash_amount_big: '零元整',
        // todo new
        // 置换金额
        displace_amount: 0,
        // todo new
        // 置换金额（大写）
        displace_amount_big: '零元整',
        // 多次换画价格
        multi_replace_price: null,
        // 验收方式
        acceptance_way: null,
        // 备注
        memo: null,
        other_memo: null,
        // 父合同ID，补充协议时使用，普通合同不传
        parent_id: null,
        // 自身媒体资源明细
        mediaDetailList: [],
        // 附件id列表
        attachmentList: [],
        // 合同列表
        documentList: [],
        // 代理情况明细
        proxyMediaDetailList: [],
        // 付款明细
        payDetailList: [],
        // 自有资源换画价格
        contractMediaReplacePriceList: [],
        // 代理资源换画价格
        contractProxyMediaReplacePriceList: [],
        // 当前人维护
        cur_user_maintenance: false,
      },
      part_a_history_list: [],
      dept_list: [],
      planDialogVisible: false,
      planListParams: {
        lockStatus: 2,
        page: 1,
        page_size: 10
      },
      planTotal: null,
      planTableLoading: false,
      planTableData: [],
      choosePlanTableData: [],
      contractUploadShow: false,
      attachUploadShow: false,
      attachType: 1,// 附件类型 0合同 1其它资料
      errorData: {},
      point_type_arr: [],
      all_media_type_name_arr: [],
      params: {}
    }
  },
  computed: {
    user_id() {
      return this.$store.state.user.id
    },
    formDisabled() {
      return this.cuForm.flow_status == 3 || this.cuForm.flow_status == 4
    },
    self_price_big() {
      return amountToBigStr(this.cuForm.self_price)
    },
    proxy_price_big() {
      return amountToBigStr(this.cuForm.proxy_price)
    },
	canUpload(){
		return this.is_created || (this.cuForm.cur_user_maintenance && this.cuForm.mode == 0);
	},
  },
  watch: {
    'cuForm.advertising_costs': {
      handler(val) {
        if (val !== null) {
          this.cuForm.advertising_costs_big = amountToBigStr(val)
        }
      }
    },
    'cuForm.discounted_price': {
      handler(val) {
        if (val !== null) {
          this.cuForm.discounted_price_big = amountToBigStr(val)
        }
      }
    },
    'cuForm.pay_cash_amount': {
      handler(val) {
        if (val !== null) {
          this.cuForm.pay_cash_amount_big = amountToBigStr(val)
        }
      }
    },
    'cuForm.displace_amount': {
      handler(val) {
        if (val !== null) {
          this.cuForm.displace_amount_big = amountToBigStr(val)
        }
      }
    },
    'cuForm.self_price': {
      handler(val) {
        if (val) {
          let sum = 0
          sum = add(val, sum)
          if (this.cuForm.proxy_price !== null) {
            sum = add(this.cuForm.proxy_price, sum)
          }
          this.cuForm.discounted_price = sum
        }
      }
    },
    'cuForm.proxy_price': {
      handler(val) {
        if (val) {
          let sum = 0
          if (this.cuForm.self_price !== null) {
            sum = add(this.cuForm.self_price, sum)
          }
          sum = add(val, sum)
          this.cuForm.discounted_price = sum
        }
      }
    },
    'cuForm.mediaDetailList': {
      handler(arr) {
        let money = 0
        for (let i = 0; i < arr.length; i++) {
          const tmp = arr[i]
          if (tmp.amount !== null) {
            money = add(tmp.amount, money)
          }
          if (tmp.quantity !== null && tmp.amount !== null && tmp.media_cycle != null) {
            tmp.price = divide(tmp.amount,multiply(tmp.quantity,tmp.media_cycle)).toFixed(2)
          }
        }
        this.cuForm.self_price = money
      },
      deep: true
    },
    'cuForm.proxyMediaDetailList': {
      handler(arr) {
        let money = 0
        for (let i = 0; i < arr.length; i++) {
          const tmp = arr[i]
          if (tmp.amount !== null) {
            money = add(tmp.amount, money)
          }
          if (tmp.quantity !== null && tmp.amount !== null && tmp.media_cycle != null) {
            tmp.price = divide(tmp.amount,multiply(tmp.quantity,tmp.media_cycle)).toFixed(2)
          }
        }
        this.cuForm.proxy_price = money
      },
      deep: true
    },
    'cuForm.payDetailList': {
      handler(payDetailList) {
        let pay_cash_amount = 0, displace_amount = 0
        // 检查付款金额
        if (payDetailList && payDetailList.length > 0) {
          let pay_cash_arr = payDetailList.filter(item => item.pay_amount !== null && item.pay_type === 1)
          let displace_arr = payDetailList.filter(item => item.pay_amount !== null && item.pay_type === 2)
          pay_cash_arr.forEach(item => {
            pay_cash_amount = add(pay_cash_amount, item.pay_amount)
          })
          displace_arr.forEach(item => {
            displace_amount = add(displace_amount, item.pay_amount)
          })
        }
        this.cuForm.pay_cash_amount = pay_cash_amount
        this.cuForm.displace_amount = displace_amount
      },
      deep: true
    }
  },
  async created() {
    const uuid = this.$route.query.uuid
    const params = this.$store.state.keep.pageParamsMap.get(uuid)
    this.params = params
    this.formLoading = true
    await get_company().then(res => {
      this.dept_list = res.data
    })
    this.initPoint_type_arr()
    this.list_media_type_include_proxy()
    if (params) {
      if (params.is_create) {
        this.is_created = true
        this.showCreatePointType = true
        this.formLoading = false
        this.initCustomerArr() // 初始化客户信息
      }
      if (params.id) {
        this.formLoading = true
        detail(params.id).then(res => {
          this.formLoading = false
          this.cuForm = res.data
          if (this.cuForm.flow_status === 3 || this.cuForm.flow_status === 4) {
            this.initCustomerList()
          } else {
            this.initCustomerArr()
          }
          this.getHistoryUser(this.cuForm.customer_id)
          this.cuForm.mediaDetailList.forEach(item => {
            listTypeSpecByMediaTypeId({ mediaTypeId: item.media_type_id }).then(res => {
              this.$set(item, 'media_type_spec_arr', res.data)
            })
          })
          this.selectDept = this.dept_list.find(item => item.id === this.cuForm.part_b_id)
        })
      }
      if (params.handle_param) {
        this.formLoading = true
        await part_a_history({ customerId: params.handle_param.id }).then(res => {
          this.part_a_history_list = res.data
        })
        detail(params.handle_param.id).then(res => {
          this.formLoading = false
          this.cuForm = res.data
          if (this.cuForm.flow_status === 3 || this.cuForm.flow_status === 4) {
            this.initCustomerList()
          } else {
            this.initCustomerArr()
          }
          this.cuForm.mediaDetailList.forEach(item => {
            listTypeSpecByMediaTypeId({ mediaTypeId: item.media_type_id }).then(res => {
              this.$set(item, 'media_type_spec_arr', res.data)
            })
          })
          this.selectDept = this.dept_list.find(item => item.id === this.cuForm.part_b_id)
        })
      }
    }
  },
  methods: {
    initPoint_type_arr() {
      list_media_types().then(
        res => {
          this.point_type_arr = res.data
        }
      )
    },
    list_media_type_include_proxy() {
      list_media_type_include_proxy().then(res => {
        this.all_media_type_name_arr = res.data
      })
    },
    initCustomerArr() {
      list_all().then(res => {
        this.customer_arr = res.data
      })
    },
    initCustomerList() {
      company_list_all().then(res => {
        this.customer_arr = res.data
      })
    },
    selectDeptChange(val) {
      if (val) {
        this.cuForm.part_b_id = val.id
        this.cuForm.part_b_name = val.head
        this.cuForm.bank_account_name = val.head
        this.cuForm.bank_name = val.bank
        this.cuForm.bank_num = val.bank_card_num
      } else {
        this.cuForm.part_b_id = null
        this.cuForm.part_b_name = null
        this.cuForm.bank_account_name = null
        this.cuForm.bank_name = null
        this.cuForm.bank_num = null
      }
    },
    selectPartAChange(val) {
      console.log(val)
      if (val instanceof Object) {
        this.cuForm.part_a = val.part_a
        this.cuForm.part_a_phone = val.part_a_phone
        this.cuForm.part_a_contact = val.part_a_contact
      } else if (val) {
        this.cuForm.part_a = val
      } else {
        this.cuForm.part_a = null
        this.cuForm.part_a_phone = null
        this.cuForm.part_a_contact = null
      }
    },
    save() {
      const flag = this.handlerProxy()
      if (!flag) {
        return
      }
      const b = this.handlerAmount()
      if (!b) {
        return
      }
      const loading = this.$loading({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      save(this.cuForm).then(res => {
        if (res.data) {
          this.$message.success('操作成功')
        } else {
          this.closeThisPage()
        }
        loading.close()
      }).catch(() => {
        loading.close()
      })
    },
    submit() {
      const flag = this.handlerProxy()
      if (!flag) {
        return
      }
      const b = this.handlerAmount()
      if (!b) {
        return
      }
      const loading = this.$loading({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      begin(this.cuForm).then(res => {
        if (res.data) {
          this.$message.success('操作成功')
        } else {
          this.closeThisPage()
        }
        loading.close()
      }).catch(() => {
        loading.close()
      })
    },
    pass(opinion) {
      const loading = this.$loading({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      pass({ id: this.cuForm.id, wf_check_opinion: opinion }).then(res => {
        this.$message.success('操作成功')
        this.closeThisPage()
        loading.close()
      }).catch(() => {
        loading.close()
      })
    },
    returnBack(opinion) {
      const loading = this.$loading({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      return_back({ id: this.cuForm.id, wf_check_opinion: opinion }).then(res => {
        this.$message.success('操作成功')
        this.closeThisPage()
        loading.close()
      }).catch(() => {
        loading.close()
      })
    },
    remove() {
      const loading = this.$loading({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      remove({ id: this.cuForm.id }).then(res => {
        this.$message.success('操作成功')
        this.closeThisPage()
        loading.close()
      }).catch(() => {
        loading.close()
      })
    },
    actualDelete() {
      const loading = this.$loading({
        lock: true,
        text: '加载中',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      })
      actual_delete({ id: this.cuForm.id }).then(res => {
        this.$message.success('操作成功')
        this.closeThisPage()
        loading.close()
      }).catch(() => {
        loading.close()
      })
    },
    closeThisPage() {
      this.$store.dispatch('tagsView/closeCurPage')
    },
    getPlanList() {
      this.planTableLoading = true
      getPlanList(this.planListParams).then(res => {
        this.planTableLoading = false
        this.planTableData = res.data.records
        this.planTotal = res.data.total
      }).catch(() => {
        this.planTableLoading = false
      })
    },
    showPlanDialog() {
      this.planDialogVisible = true
      this.getPlanList()
    },
    handleCurrentChange(val) {
      this.planListParams.page = val
      this.getPlanList()
    },
    /**
     * 关闭选取方案弹框
     */
    closePlanDialog() {
      this.planListParams.page = 1
      this.choosePlanTableData = []
    },
    /**
     * 选中方案
     * @param row
     */
    selectPlan(row) {
      this.choosePlanTableData.push(Object.assign({}, row))
    },
    /**
     * 删除选中方案
     * @param index
     */
    removeChoosePlan(index) {
      this.choosePlanTableData.splice(index, 1)
    },
    addPlan() {
      this.plan_list = this.plan_list.concat(this.choosePlanTableData.map(item => {
        return {
          id: item.id,
          plan_name: item.plan_name
        }
      }))
      this.planDialogVisible = false
    },
    removePlan(index) {
      this.$confirm('确定移除此方案?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.plan_list.splice(index, 1)
      }).catch(() => {
      })
    },
    typeChange(val) {
      if (!val && this.plan_list.length > 0) {
        this.$confirm('切换到选位将丢失已选择的方案数据?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.plan_list = []
        }).catch(() => {
          this.flag = true
        })
      }
    },
    // next() {
    //   this.$refs['cuForm'].validate((valid) => {
    //     if (valid) {
    //       this.cuForm.intention_scheme_id_list = this.plan_list.map(item => {
    //         return item.id
    //       })
    //       /**
    //        * 生成合同
    //        */
    //       if (this.flag) {
    //         const loading = this.$loading({
    //           lock: true,
    //           text: '加载中',
    //           spinner: 'el-icon-loading',
    //           background: 'rgba(0, 0, 0, 0.7)'
    //         })
    //         generate(this.cuForm).then(
    //           res => {
    //             detail(res.data).then(respose => {
    //               this.formLoading = false
    //               this.cuForm = respose.data
    //               this.$set(this.cuForm, 'tmpDataList', formatData(respose))
    //               this.$set(this.cuForm, 'dataList', [])
    //               this.showCreatePointType = false
    //               this.showInfo = false
    //               loading.close()
    //             })
    //           }
    //         ).catch(() => {
    //           loading.close()
    //         })
    //       } else {
    //         this.centerDialogVisible = true
    //         this.date_range = [this.getDateStr(new Date()), this.getDateStr(new Date())]
    //       }
    //     } else {
    //       this.$message.warning('请填写基本信息')
    //     }
    //   })
    // },
    showPointSelect() {
      this.positionSelectionDialogVisible = true
      this.centerDialogVisible = false
      this.showCreatePointType = false
      this.showInfo = false
    },
    closeContractUpload() {
      this.contractUploadShow = false
    },
    closeAttachUpload() {
      this.attachUploadShow = false
    },
    showContractUpload() {
      this.contractUploadShow = true
      this.attachType = 1
    },
    showOtherUpLoad() {
      this.attachUploadShow = true
      this.attachType = 2
    },
    /**
     * 文件上传
     * @param data
     */
    uploadSuccess(data) {
      if (this.attachType == 1){
        this.cuForm.attachmentList.push(Object.assign({}, data))
      }else{
        this.cuForm.documentList.push(Object.assign({}, data))
      }
      this.closeUpload();
      // 合同已通过审核，为后补合同，需要调用保存
      if(this.cuForm.cur_user_maintenance && this.cuForm.mode == 0 && !this.is_created && !!this.cuForm.id){
        const loading = this.$loading({
          lock: true,
          text: '保存附件中',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        })
        saveAttachment(this.cuForm).then(res => {
          loading.close()
          if (res.data) {
            this.$message.success('保存附件成功')
          }else{
            this.$message.error('保存附件失败');
            this.cuForm.attachmentList = this.cuForm.attachmentList.slice(0, this.cuForm.attachmentList.length - 1);
            this.cuForm.documentList = this.cuForm.documentList.slice(0, this.cuForm.documentList.length - 1);
          }
        }).catch(() => {
           loading.close();
          this.$message.error('保存附件失败');
          this.cuForm.attachmentList = this.cuForm.attachmentList.slice(0, this.cuForm.attachmentList.length - 1);
          this.cuForm.documentList = this.cuForm.documentList.slice(0, this.cuForm.documentList.length - 1);
        })
      }
    },
    removeAttachment(index) {
      this.$confirm('是否确定删除资料', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.cuForm.documentList.splice(index, 1)
      }).catch(() => {
      })
    },
    removeContract(index) {
      this.$confirm('是否确定删除合同', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.cuForm.attachmentList.splice(index, 1)
      }).catch(() => {
      })
    },
    add() {
      this.cuForm.proxyMediaDetailList.push({
        proxy_media_type: null,
        media_type_spec: null,
        media_cycle: null,
        media_cycle_unit: null,
        quantity: null,
        duration: null,
        amount: null,
        price:null,
        talk_price: null
      })
    },
    deleteByIndex(index) {
      this.cuForm.proxyMediaDetailList.splice(index, 1)
    },
    /**
     * 自由资源添加
     */
    myAdd() {
      this.cuForm.mediaDetailList.push({
        media_type_id: null,
        media_type_spec_arr: [],
        media_type_spec_id: null,
        media_cycle: null,
        media_cycle_unit: null,
        quantity: null,
        duration: null,
        amount: null,
        price:null,
        talk_price: null
      })
    },
    /**
     * 自由资源删除
     * @param index
     */
    myDeleteByIndex(index) {
      this.cuForm.mediaDetailList.splice(index, 1)
    },
    /**
     * 获取搜索默认配置项
     * @param index
     * @param type 1:增加排斥点位 2:增加排斥楼盘 3:复用楼盘
     * @param date 时间
     * @param arr 数据（排斥的点位数据或排斥的楼盘或复用的楼盘）
     * @param pointTypeArr 选中的点位类型数据
     * @param configType 配置项的类型
     * @param disabled 增加的配置是否可以换类型
     */
    getSearchConfig(index, type, date, arr, pointTypeArr, configType, disabled) {
      this.tmpIndex = index
      if (type == 1) {
        this.exclude_media_id_list = arr
      } else if (type == 2) {
        this.exclude_building_id_list = arr
      } else {
        this.buildingList = arr
      }
      this.date_range = date
      this.pointTypeIdList = pointTypeArr
      this.type = configType
      this.disabled = disabled
      this.positionSelectionDialogVisible = true
    },
    editConfigBuildingData(configIndex, buildingId, pointTypeId, mediaArr, isConflict = false) {
      if (isConflict) {
        this.cuForm.tmpDataList[configIndex].dataArr.forEach(item => {
          if (item.id == buildingId) {
            mediaArr.forEach(tmp => {
              const find = item.pointTypeCountVOMap[pointTypeId].mediaPointList.find(point => point.id == tmp.id)
              if (find) {
                item.pointTypeCountVOMap[pointTypeId].to--
                find.checked = false
              }
            })
          }
        })
      } else {
        this.cuForm.tmpDataList[configIndex].dataArr.forEach(item => {
          if (item.id == buildingId) {
            mediaArr.forEach(tmp => {
              const find = item.pointTypeCountVOMap[pointTypeId].mediaPointList.find(point => point.id == tmp.id)
              if (find) {
                if (find.checked != tmp.checked) {
                  if (tmp.checked) {
                    item.pointTypeCountVOMap[pointTypeId].to++
                  } else {
                    item.pointTypeCountVOMap[pointTypeId].to--
                  }
                  find.checked = tmp.checked
                }
              } else {
                item.pointTypeCountVOMap[pointTypeId].push(Object.assign({}, find))
              }
            })
          }
        })
      }
    },
    getDateStr(date) {
      return date.getFullYear() + '-' + ((date.getMonth() + 1) > 9 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1)) + '-' + (date.getDate() > 9 ? date.getDate() : ('0' + date.getDate()))
    },
    download(url) {
      if (url) {
        window.open(url, '_blank')
      } else {
        this.$message.error('文件不存在！请联系管理员')
      }
    },
    handlerProxy() {
      let sum = 0
      if (this.cuForm.self_price) {
        sum = add(this.cuForm.self_price, sum)
      }
      if (this.cuForm.proxy_price) {
        sum = add(this.cuForm.proxy_price, sum)
      }
      if (sum != this.cuForm.discounted_price) {
        this.$message.error('自有资源金额和代理资源相加不等于优惠价格 请调整！')
        return false
      } else {
        if (this.cuForm.proxyMediaDetailList.length == 0 && !(this.cuForm.proxy_price)) {
          return true
        } else {
          let sum2 = 0
          this.cuForm.proxyMediaDetailList.forEach(item => {
            sum2 = add(sum2, item.amount)
          })
          if (sum2 != this.cuForm.proxy_price) {
            this.$message.error('代理资源明细总额不等于代理资源价格 请调整！')
            return false
          } else {
            return true
          }
        }
      }
    },
    /**
     *
     * @returns {boolean}
     */
    handlerAmount() {
      // if (!this.cuForm.payDetailList || (this.cuForm.payDetailList && this.cuForm.payDetailList.length === 0)) {
      //   this.$message.error('支付明细至少有一项')
      //   return false
      // }
      let sum = 0
      if (this.cuForm.pay_cash_amount) {
        sum = add(this.cuForm.pay_cash_amount, sum)
      }
      if (this.cuForm.displace_amount) {
        sum = add(this.cuForm.displace_amount, sum)
      }
      if (sum == this.cuForm.discounted_price) {
        return true
      } else {
        this.$message.error('现金金额加上置换金额不等于优惠价格')
        return false
      }
    },
    addPay() {
      this.cuForm.payDetailList.push({
        pay_time: null,
        pay_amount: null,
        pay_type: null
      })
    },
    deletePayByIndex(index) {
      this.cuForm.payDetailList.splice(index, 1)
    },
    mediaTypeChange(index, mediaTypeId) {
      this.cuForm.mediaDetailList[index].media_type_spec_id = null
      listTypeSpecByMediaTypeId({ mediaTypeId }).then(res => {
        res.data.push('无')
        this.cuForm.mediaDetailList[index].media_type_spec_arr = res.data
      })
    },
    look(url) {
      const fileName = url.substring(url.lastIndexOf('.') + 1)
      if (fileName === 'pdf') {
        window.open(url, '_blank')
      } else {
        const str = 'https://view.officeapps.live.com/op/view.aspx?src=' + url
        window.open(str, '_blank')
      }
    },
    getHistoryUser(id) {
      this.part_a_history_list = []
      //this.cuForm.part_a = null
      part_a_history({ customerId: id }).then(res => {
        this.part_a_history_list = res.data
      })
    },
    priceAdd(type) {
      if (type === 1) {
        this.cuForm.contractMediaReplacePriceList.push({
          media_type_id: null,
          replace_price: null
        })
      } else {
        this.cuForm.contractProxyMediaReplacePriceList.push({
          media_type_name: null,
          replace_price: null
        })
      }
    },
    priceRemove(type, index) {
      if (type === 1) {
        this.cuForm.contractMediaReplacePriceList.splice(index, 1)
      } else {
        this.cuForm.contractProxyMediaReplacePriceList.splice(index, 1)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.contract_title {
  width: 80%;
  margin: 0 auto;
  text-align: right;
}

.contract_content p {
  width: 80%;
  margin: 0 auto;
  line-height: 50px;
  font-size: 18px;
}

.p_title {
  font-weight: bold;
}

.header {
  padding-top: 20px;
  text-align: center;
  font-size: 25px;
  font-weight: bold;
  margin: 10px auto;
}

/**
 去除el-form-item的下边距
 */
/deep/ .cuForm .el-form-item {
  margin-bottom: 0;
  display: inline-block;
}

/**
去除el-form-item__content的左边距
 */
/deep/ .cuForm .el-form-item__content {
  margin-left: 0 !important;
  display: inline-block;
}

/deep/ .cuForm .el-input.is-disabled .el-input__inner {
  background-color: white;
  color: black;
}

/deep/ .cuForm .el-textarea.is-disabled .el-textarea__inner {
  background-color: white;
  color: black;
}

.two_title {
  text-align: center;
  font-size: 20px;
  font-weight: bold;
  margin: 10px auto;
}

.border_none {
  border: none !important;
}

/deep/ .proxyTable .el-form-item__error {
  position: relative;
}

.table_body {
  margin-bottom: 20px;
}

/deep/ .fill_table .el-table__cell {
  padding: 0;
}
</style>
